﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;

namespace MO
{
    public static class ExtensionMethods
    {
        static string chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        public static string To16String(this Guid guid)
        {
            string result = "";
            foreach (byte b in guid.ToByteArray())
            {
                result += chars[b % 36];
            }
            return result;
        }
        
    }
    public class MD5
    {
        public static string MD5Hash(string inputString)
        {
            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
            byte[] encryptedBytes = md5.ComputeHash(Encoding.ASCII.GetBytes(inputString));
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < encryptedBytes.Length; i++)
            {
                sb.AppendFormat("{0:x2}", encryptedBytes[i]);
            }
            return sb.ToString();
        }
    }
}
